package org.fastsyncer.connector.database;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.fastsyncer.common.entity.DataSourceConfig;
import org.fastsyncer.common.entity.DataSourceConnector;
import org.fastsyncer.connector.framework.Connector;
import org.springframework.jdbc.core.JdbcTemplate;

public interface Database extends Connector {

	public JdbcTemplate getJdbcTemplate(DataSourceConfig config);

	public DataSourceConnector getDataSourceConnector(DataSourceConfig config);
	
	public DataSourceConnector getDataSourceConnector(DataSourceConfig config, String queryFilter);

	/**
	 * 
	 * @param opertion 增删改查
	 * @param config	数据源配置
	 * @param fileds	数据源字段
	 * @param queryFilter 条件
	 * @return
	 */
	public String getJdbcSQL(String opertion, DataSourceConfig config, List<HashMap<String, Object>> fileds, String queryFilter);

	/**
	 * 
	 * @param ps
	 *            参数构造器
	 * @param fileds
	 *            同步字段，例如[{name=ID, type=4}, {name=NAME, type=12}]
	 * @param row
	 *            同步字段对应的值，例如{ID=123, NAME=张三11}
	 * @throws NumberFormatException
	 * @throws SQLException
	 */
	public void batchRowsSetter(PreparedStatement ps, List<HashMap<String, Object>> fileds, Map<String, Object> row) throws Exception;

}
